package com.biaobiaoqi.scoreanalysis.administrator.action;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.biaobiaoqi.scoreanalysis.exception.DuplicateCourseException;
import com.biaobiaoqi.scoreanalysis.service.ICourseService;
import com.opensymphony.xwork2.ActionSupport;

public class AddCourse extends ActionSupport {
	private static final Log log = LogFactory.getLog(AddCourse.class);
 	private static final long serialVersionUID = -4718768094531506399L;
 	private String courseName;
 	private int clazzType;
 	@Resource
 	ICourseService courseService;
 	public String execute() {
		try {
			courseService.addCourse(courseName, clazzType);
			return SUCCESS;
		} catch (DuplicateCourseException e) {
			log.debug("课程已存在！",e);
			addActionError("课程："+courseName+"已存在");
			return INPUT;
		} catch (Exception e) {
			log.error("服务器内部错误",e);
			return ERROR;
		}
	}
	public String getCourseName() {
		return courseName;
	}
	public void setCourseName(String courseName) {
		this.courseName = courseName;
	}
	public int getClazzType() {
		return clazzType;
	}
	public void setClazzType(int clazzType) {
		this.clazzType = clazzType;
	}
	public ICourseService getCourseService() {
		return courseService;
	}
	public void setCourseService(ICourseService courseService) {
		this.courseService = courseService;
	}
}
